package com.kgcx.system.controller;

import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.system.domain.Menu;
import com.kgcx.system.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 何凯
 * @version 0.1
 * @description
 * @time 2017/12/14 11:50
 * @since 0.1
 */
@Api(description = "系统菜单", tags = "系统菜单接口")
@RestController
@RequestMapping("sys/v1/menu")
public class MenuController extends BaseController{
    @Autowired
    private MenuService menuService;

    @ApiOperation(value = "系统所有菜单", httpMethod = "GET", notes = "系统所有菜单接口")
	@GetMapping(value = "queryAll")
	public ReturnData<List<Menu>> queryMenuAll() {
        List<Menu> list = menuService.queryMenuList();
		return new ReturnData<>(list);
	}

	@ApiOperation(value = "用户查询拥有的菜单", httpMethod = "GET", notes = "用户查询拥有的菜单接口")
	@ApiImplicitParams({
		 @ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query", dataType = "Integer", dataTypeClass = Integer.class)
	})
	@GetMapping(value = "queryMenuByRole")
	public ReturnData<List<Menu>> queryMenuByRole(@RequestParam Integer userId) {
        List<Menu> list = menuService.queryMenuListByUser(userId);
		return new ReturnData<>(list);
	}

}
